<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2024/9/4
  Time: 9:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>Space</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/bootstrap-fileinput/4.4.7/css/fileinput.min.css" media="all" rel="stylesheet"
          type="text/css"/>
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div id="wrapper" class="toggled">
    <nav class="navbar navbar-inverse navbar-fixed-top" id="sidebar-wrapper" role="navigation">
        <ul class="nav sidebar-nav">
            <li class="sidebar-brand">
                <a href="/categoryList">
                    商家管理系统
                </a>
            </li>
            <li class="sidebar-brand">
                <a href="#">
                    您好, ${username}
                </a>
            </li>
            <li>
                <a href="/userServlet"><i class="fa fa-fw fa-list-alt"></i> 用户管理</a>
                <a href="/userOperateServlet?operate=add"><i class="fa fa-fw fa-list-alt"></i>用户新增</a>
            <li><a href="/categoryServlet"><i class="fa fa-fw fa-list-alt"></i>类目管理</a></li>
            <li><a href="/categoryOperateServlet?operate=add"><i class="fa fa-fw fa-list-alt"></i>类目新增</a></li>

            </li>
            <li class="dropdown open">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true"><i
                        class="fa fa-fw fa-plus"></i> 商品 <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li class="dropdown-header">操作</li>
                    <li><a href="/productInfoByPageServlet">列表</a></li>
                    <li><a href="/productOperateServlet?operate=add"><i class="fa fa-fw fa-list-alt"></i>新增</a></li>
                </ul>
            </li>
            <li class="dropdown open">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true"><i
                        class="fa fa-fw fa-plus"></i> 类目 <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li class="dropdown-header">操作</li>
                    <li><a href="#">列表</a></li>
                    <li><a href="categoryListByPage">分页列表</a></li>
                    <li><a href="insertCategoryServlet">新增</a></li>
                </ul>
            </li>

            <li>
                <a href=""><i class="fa fa-fw fa-list-alt"></i> 登出</a>
            </li>
        </ul>
    </nav>
    <div id="container">
        <div class="container-fluid">
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <h3 style="text-align: center"><a href="#">类目信息列表</a></h3>
                    <form class="form-inline" action="/categoryServlet" method="post">
                        <div class="form-group">
                            <label>类目名</label>
                            <input type="text" name="category_name" class="form-control" value="${category_name}">
                        </div>
                        <button type="submit" class=" btn btn-success">查询</button>
                    </form>
                    <table class="table table-bordered table-condensed">
                        <thead>
                        <tr>
                            <th>类目Id</th>
                            <th>类目名字</th>
                            <th>类目编号</th>
                            <th>创建时间</th>
                            <th>修改时间</th>
                            <th colspan="2">操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <c:forEach var="category" items="${pb.list}" varStatus="loop">
                            <c:choose>
                                <c:when test="${loop.index %2==1}">
                                    <tr class="success">
                                        <td>${category.category_id}</td>
                                        <td>${category.category_name}</td>
                                        <td>${category.category_type}</td>
                                        <td>${category.create_time}</td>
                                        <td>${category.update_time}</td>
                                        <td>
                                            <a href="/categoryOperateServlet?category_id=${category.category_id}&operate=del ">删除</a>
                                        </td>
                                        <td>
                                            <a href="/categoryOperateServlet?category_id=${category.category_id}&operate=update ">修改</a>
                                        </td>
                                    </tr>
                                </c:when>
                                <c:otherwise>
                                    <tr class="warning">
                                        <td>${category.category_id}</td>
                                        <td>${category.category_name}</td>
                                        <td>${category.category_type}</td>
                                        <td>${category.create_time}</td>
                                        <td>${category.update_time}</td>
                                        <td>
                                            <a href="/categoryOperateServlet?category_id=${category.category_id}&operate=del ">删除</a>
                                        </td>
                                        <td>
                                            <a href="/categoryOperateServlet?category_id=${category.category_id}&operate=update ">修改</a>
                                        </td>
                                    </tr>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>

                        </tbody>
                    </table>
                </div>

                <!--                分页-->
                <div class="col-md-12 column">
                    <ul class="pagination pull-right">
                        <c:if test="${pb.currentPage==1}">
                            <li><a class="disabled" href="#">上一页</a></li>
                        </c:if>
                        <c:if test="${pb.currentPage!=1}">
                            <li>
                                <a href="/categoryServlet?currentPage=${pb.currentPage-1}&category_name=${category_name}">上一页</a>
                            </li>
                        </c:if>
                        <c:forEach begin="1" end="${pb.totalPage}" var="i">
                            <%--              当前页有特殊效果--%>
                            <c:if test="${pb.currentPage==i}">
                                <li class="active"><a
                                        href="/categoryServlet?currentPage=${i}&category_name=${category_name}">${i}</a>
                                </li>
                            </c:if>
                            <%--              其他页--%>
                            <c:if test="${pb.currentPage!=i}">
                                <li>
                                    <a href="/categoryServlet?currentPage=${i}&category_name=${category_name}">${i}</a>
                                </li>
                            </c:if>
                        </c:forEach>
                        <%--            下一页--%>
                        <c:if test="${pb.currentPage==pb.totalPage}">
                            <li><a class="disabled" href="#">下一页</a></li>
                        </c:if>
                        <c:if test="${pb.currentPage!=pb.totalPage}">
                            <li>
                                <a href="/categoryServlet?currentPage=${pb.currentPage+1}&category_name=${category_name}">下一页</a>
                            </li>
                        </c:if>
                    </ul>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>
